//
//  UIBarButtonItem+Extensions.swiftl.
//  Weibo
//
//  Created by LioWu on 03/04/2017.
//  Copyright © 2017 MyGit. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(title:String,
                     fontSize: CGFloat = 16,
                     target: Any?,
                     action: Selector,
                     isBack: Bool = false) {
        
        let textButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.gray, highlightedColor: UIColor.orange)
        
        if isBack {
            let imageName = "navigationbar_back_withtext"
            textButton?.setImage(UIImage.init(named: imageName), for: .normal)
            textButton?.setImage(UIImage.init(named: imageName + "_highlighted"), for: .highlighted)
            textButton?.sizeToFit()
        }
        
        textButton?.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView: textButton!)
    }
}
